﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using GraphProcessor;

namespace IQIGame.Onigao.GamePlay.Editors
{
	public class LevelServiceGraphWindow : BaseGraphWindow
	{
		LevelServiceGraph tmpGraph;
		LevelServiceToolbarView toolbarView;

		[MenuItem("Window/07 LevelService Combined")]
		public static BaseGraphWindow OpenWithTmpGraph()
		{
			var graphWindow = CreateWindow<LevelServiceGraphWindow>();

			// When the graph is opened from the window, we don't save the graph to disk
			graphWindow.tmpGraph = ScriptableObject.CreateInstance<LevelServiceGraph>();
			graphWindow.tmpGraph.hideFlags = HideFlags.HideAndDontSave;
			graphWindow.InitializeGraph(graphWindow.tmpGraph);

			graphWindow.Show();

			return graphWindow;
		}

		protected override void OnDestroy()
		{
			graphView?.Dispose();
			DestroyImmediate(tmpGraph);
		}

		protected override void InitializeWindow(BaseGraph graph)
		{
			titleContent = new GUIContent($"LevelService : {graph.name}");

			if (graphView == null)
			{
				graphView = new LevelServiceGraphView(this);
				toolbarView = new LevelServiceToolbarView(graphView);
				graphView.Add(toolbarView);
			}

			rootView.Add(graphView);
		}

		protected override void InitializeGraphView(BaseGraphView view)
		{
			// graphView.OpenPinned< ExposedParameterView >();
			// toolbarView.UpdateButtonStatus();
		}
		
		private void OnInspectorUpdate()
		{
			Repaint();
		}
	}
}